<?php

/**
 * Description of NewApartamentListPreValidator
 *
 * @author verminu
 */
class NewApartamentListPreValidator extends sfValidatorSchema
{
  const APARTAMENTE_REQUIRED = 'apartamente_required';

  public function configure($options = array(), $messages = array())
  {
    parent::configure($options, $messages);

    $this->addMessage(self::APARTAMENTE_REQUIRED, 'Nu aţi completat nimic !');
  }

  /**
   * Apartamentele care nu sunt completate se ignora
   *
   * @param type $values
   * @return type
   */
  protected function doClean($values)
  {
    if (count($values[NewApartamentListForm::WRAPPER_NAME]) == 0)
    {
      throw new sfValidatorError($this, self::APARTAMENTE_REQUIRED);
    }

    return $values;
  }

}
